//
//  HWMembersCenterViewController.m
//  HWanGame
//
//  Created by 陈道斌 on 2019/10/31.
//  Copyright © 2019 Chendaobin. All rights reserved.
//

#import "HWMembersCenterViewController.h"
#import "HWMembersTableViewCell.h"
#import "HWzhizunhuiView.h"
#import "HWOpenTheRecordViewController.h" // 账单记录

@interface HWMembersCenterViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(strong,nonatomic) UITableView *mainaTableVie;
@property(strong,nonatomic) UIView *headView;
@property(strong,nonatomic) UIImageView *touxiangimageView;
@property(strong,nonatomic) UILabel *mingchenglabel;
@property(strong,nonatomic) UIImageView *zuanimageView;
@property(strong,nonatomic) UILabel *dataLabel;
@property(strong,nonatomic) UILabel *zhizongLabel;
@property(strong,nonatomic) UIView *footView;
@property(strong,nonatomic) NSMutableArray *butMuArr;
@property(strong,nonatomic) NSString *typePayStr; // 0代表支付宝支付 1代表微信  2 代表余额
@property(strong,nonatomic) HWzhizunhuiView *zhizunhui; // 至宗会员
@property(strong,nonatomic) UIButton *zhangdangbutt; // 账单




@end

@implementation HWMembersCenterViewController

-(UITableView *)mainaTableVie {

    if  (_mainaTableVie == nil) {

        _mainaTableVie = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH) style:UITableViewStylePlain];
        _mainaTableVie.delegate = self;
        _mainaTableVie.dataSource = self;
        _mainaTableVie.separatorStyle = UITableViewCellSeparatorStyleNone;
        
        _mainaTableVie.backgroundColor = [UIColor whiteColor];
       // _mainaTableVie.backgroundColor = RGB(241, 242, 244);
        
    }
    return   _mainaTableVie ;

}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self setupUI];
    
}

// 设置UI
- (void)setupUI {
    
    
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationItem.title = @"会员中心";
    [self.view addSubview:self.mainaTableVie];
    
    [self addheadView];
    [self addFootView];
}



// 给tablview添加HederView
- (void)addheadView {
    
    self.headView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 150+36)];
    self.mainaTableVie.tableHeaderView = self.headView;
    
    UIImageView *backImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 150)];
    backImageView.image = [UIImage imageNamed:@"vip_bg_ member"];
    [self.headView addSubview:backImageView];
    
    
     UIButton *zhangdangbutt = [UIButton buttonWithType:UIButtonTypeCustom];
     zhangdangbutt.frame = CGRectMake(kScreenW-40, 10, 35, 40);
     [zhangdangbutt setImage:[UIImage imageNamed:@"vip_rec_ member"] forState:UIControlStateNormal];
    [zhangdangbutt addTarget:self action:@selector(zhangdangbuttTap) forControlEvents:UIControlEventTouchUpInside];
    self.zhangdangbutt = zhangdangbutt;
    
    [self.headView addSubview:zhangdangbutt];
     
    
    
    
     self.touxiangimageView = [[UIImageView alloc]initWithFrame:CGRectMake(17, 46, 62,62)];
   //    self.touxiangimageView.image = [UIImage imageNamed:@"personal_bg"];
     // self.touxiangimageView.backgroundColor = [UIColor redColor];
      self.touxiangimageView.image = [UIImage imageNamed:@"morenTuPenson_ico"];
      self.touxiangimageView.layer.cornerRadius  = 29;
      self.touxiangimageView.layer.masksToBounds = YES;
      self.touxiangimageView.userInteractionEnabled = YES;
      self.touxiangimageView.layer.borderWidth = 2;
      self.touxiangimageView.layer.borderColor = RGB(178, 208, 255).CGColor;
      [self.headView addSubview:self.touxiangimageView];
      
      self.mingchenglabel  = [[UILabel alloc]initWithFrame:CGRectMake(self.touxiangimageView.right+13, self.touxiangimageView.top+10+3, 40, 14)];
      self.mingchenglabel.text = @"CIRES";
      self.mingchenglabel.font = [UIFont systemFontOfSize:14];
      self.mingchenglabel.textColor = [UIColor whiteColor];
   //   self.mingchenglabel.backgroundColor = [UIColor redColor];
      [self.headView addSubview:self.mingchenglabel];
      
      UIImageView *zuanimageView = [[UIImageView alloc]initWithFrame:CGRectMake(self.mingchenglabel.right+6, self.touxiangimageView.top+10+3, 16, 14)];
      zuanimageView.image = [UIImage imageNamed:@"personal_vip"];
      self.zuanimageView = zuanimageView;
      [self.headView addSubview:zuanimageView];
    
       self.dataLabel  = [[UILabel alloc]initWithFrame:CGRectMake(self.touxiangimageView.right+13, self.mingchenglabel.bottom+10, 260, 12)];
         self.dataLabel.text = @"暂未开通会员";
         self.dataLabel.font = [UIFont systemFontOfSize:12];
         self.dataLabel.textColor = [UIColor whiteColor];
      //   self.mingchenglabel.backgroundColor = [UIColor redColor];
         [self.headView addSubview:self.dataLabel];
    
    
     self.zhizongLabel  = [[UILabel alloc]initWithFrame:CGRectMake(14, backImageView.bottom, 140, 36)];
        self.zhizongLabel.text = @"至尊会员";
        self.zhizongLabel.font = [UIFont systemFontOfSize:14];
        self.zhizongLabel.textColor = RGB(51, 51, 51);
     //   self.mingchenglabel.backgroundColor = [UIColor redColor];
      [self.headView addSubview:self.zhizongLabel];
    
    
    
}
//添加footView
- (void)addFootView {
    
    self.footView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 99+190)];
    self.footView.backgroundColor = [UIColor redColor];
    self.mainaTableVie.tableFooterView = self.footView;
    
    
    UIView *zhifufanshiview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, 99)];
    zhifufanshiview.backgroundColor = [UIColor whiteColor];
    [self.footView addSubview:zhifufanshiview];
    
//    for (int i = 0 ; i < ; <#increment#>) {
//        <#statements#>
//    }
    
    self.butMuArr = [[NSMutableArray alloc]init];
    CGFloat buttonW = (kScreenW-12*4)/3;
    
    NSArray *titleArr = @[@"支付宝支付",@"微信支付",@"余额支付"];
    for (int i = 0; i < 3; i++) {
        UIButton *but  = [UIButton setButtonWithFrame:CGRectMake(12+12*i+buttonW*i,8,buttonW, 35) Title:titleArr[i] Image:nil Font:14 Color:RGB(51, 51, 51) Target:self Selector:@selector(payTap:)];
        but.layer.borderWidth  =  1;
        but.layer.borderColor = RGB(232, 232, 232).CGColor;
        but.layer.cornerRadius = 1;
        but.layer.masksToBounds = YES;
        but.tag = i;
        [zhifufanshiview addSubview:but];
        
        if (i == 0) {
            but.layer.borderColor = RGB(38, 154, 255).CGColor;
            but.layer.cornerRadius = 1;
            self.typePayStr = @"0";
            
            
        }
        
        [self.butMuArr addObject:but];
        
        
    }
    
    
    
        UIButton *lijikaitonbut  = [UIButton setButtonWithFrame:CGRectMake(65,8+35+15,kScreenW-65*2, 30) Title:@"立即开通" Image:nil Font:14 Color:RGB(255, 255, 255) Target:self Selector:@selector(payTap:)];
//        lijikaitonbut.layer.borderWidth  =  1;
//        lijikaitonbut.layer.borderColor = RGB(232, 232, 232).CGColor;
        lijikaitonbut.layer.cornerRadius = 15;
        lijikaitonbut.layer.masksToBounds = YES;
        lijikaitonbut.backgroundColor = blueBackgroundBT;
        [zhifufanshiview addSubview:lijikaitonbut];
    
    
    self.zhizunhui = [[HWzhizunhuiView alloc]initWithFrame:CGRectMake(0, 99, kScreenW, 190)];
    self.zhizunhui.backgroundColor = [UIColor whiteColor];
    [self.footView addSubview: self.zhizunhui];
    
    
    
    
}



#pragma mark ----------- 点击支付a按钮
- (void)payTap:(UIButton *)sender {
    
  
    NSInteger tap = sender.tag;
    DLog(@"数据 ： %d",tap);
    self.typePayStr = [NSString stringWithFormat:@"%d",tap];
    
    for (int i = 0; i < self.butMuArr.count; i++) {
        
        UIButton *but  = (UIButton *)self.butMuArr[i];
        
        but.layer.borderColor = RGB(232, 232, 232).CGColor;
        but.layer.cornerRadius = 1;
        
        
        
        
        
    }
    
      UIButton *but1  = (UIButton *)self.butMuArr[tap];
       but1.layer.borderColor = RGB(38, 154, 255).CGColor;
           but1.layer.cornerRadius = 1;
    
    

    
}


#pragma mark -------  点击账单按钮
- (void)zhangdangbuttTap {
    
    
    DLog(@"12345");
    
    HWOpenTheRecordViewController  *openTheRecord = [[HWOpenTheRecordViewController alloc]init];
    [self.navigationController pushViewController:openTheRecord animated:YES];
    
    
}


#pragma mark ------- tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return  3;
    
    
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *cellID = @"cellID";
    
    HWMembersTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    
    if (!cell) {
        cell = [[NSBundle mainBundle]loadNibNamed:@"HWMembersTableViewCell" owner:nil options:nil].lastObject;
        
    }
    
    
    cell.backgroundColor = [UIColor whiteColor];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    if (indexPath.row == 0) {
        cell.beijingView.backgroundColor = RGB(237, 237, 237);
        cell.name1Label.textColor = RGB(67, 67, 67);
        cell.name2Label.textColor = RGB(102, 102, 102);
        cell.name3Label.textColor = RGB(51, 51, 51);
        cell.name4Label.textColor = RGB(51, 51, 51);
        cell.icoiamgeView.image = [UIImage imageNamed:@"imgzs1_ member"];
        
        cell.name1Label.text = @"经典月卡（30天）";
        cell.name2Label.text = @"开通立返680平台币";
        cell.name3Label.text = @"￥68.00";
        cell.name4Label.text =@"专属头衔";
        
    }  else if (indexPath.row == 1) {
        
        
        cell.beijingView.backgroundColor = RGB(210, 179, 132);
        cell.name1Label.textColor = RGB(67, 67, 67);
        cell.name2Label.textColor = RGB(255, 255, 255);
        cell.name3Label.textColor = RGB(51, 51, 51);
        cell.name4Label.textColor = RGB(51, 51, 51);
        cell.icoiamgeView.image = [UIImage imageNamed:@"imgzs2_ member"];
               
        cell.name1Label.text = @"典藏季卡（90天）";
        cell.name2Label.text = @"开通立返1980平台币";
        cell.name3Label.text = @"￥198.00";
        cell.name4Label.text =@"专属头衔";
               
        
        
    } else if (indexPath.row == 2) {
        
        
        cell.beijingView.backgroundColor = RGB(67, 67, 67);
               cell.name1Label.textColor = RGB(255, 212, 144);
               cell.name2Label.textColor = RGB(255, 255, 255);
               cell.name3Label.textColor = RGB(245, 204, 140);
               cell.name4Label.textColor = RGB(255, 211, 147);
               cell.icoiamgeView.image = [UIImage imageNamed:@"imgzs3_ member"];
                      
               cell.name1Label.text = @"至尊年卡（365天）";
               cell.name2Label.text = @"开通立返6880平台币";
               cell.name3Label.text = @"￥688.00";
               cell.name4Label.text =@"专属头衔";
        
        
        
    }
    
    
    return  cell;
    
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    return  68;
}




@end
